
#ifndef __INKLUDE_C_LUA_H__
#define __INKLUDE_C_LUA_H__

#include <memory>
#include <string>
#include <vector>

extern "C" {
struct lua_State;
typedef int (*pfLuaFunction)(struct lua_State *pLuaState);
}

#include <Inklude/Inklude.h>

namespace Inklude
{

    class INKLUDE_CLASS_EXPORT ikCLua{
    public :
	    ikCLua();
    //	IceLua(HWND);
	    virtual			~ikCLua();
	    bool			RunScriptFile (const char* pFileName);
	    bool			RunString (const char* pCommand);
	    const char*		GetErrorString ();
	    bool			AddFunction (const char* pFunctionName, pfLuaFunction pfFunction);
	    const char*		GetStringArgument (int num, const char* pDefault=NULL);
	    double			GetNumberArgument (int num, double dDefault=0.0);
	    void*			GetPointerArgument (int num, double dDefault = 0.0) ;
	    void			PushString (const char* pString);
	    void			PushNumber (double dValue);
	    void			PushPointer(int value);
	    void			SetErrorHandler(void(*pErrHandler)(const char *pError)) {m_pErrorHandler = pErrHandler;}
	    void			ConstructFunctionTable(const char *tableName);
	    void			DoString(const char* command);

	    double			GetNumber(const char* varName);
	    const char*		GetString(const char* varName);
	    double			GetNumberFromTable (const char* tableName, 
										    const char* fieldName);
	    const char* 	GetStringFromTable (const char* tableName, 
										    const char* filedName);

	    void			ExecLuaFile(const char* fileName);


    private :
	    lua_State*		m_pScriptContext;
	    void			(*m_pErrorHandler)(const char *pError);
	    std::vector<std::string *> functionNames;
	    const char*     getStringField(const char* fieldName);
	    double			getNumberField(const char* fieldName);
        std::vector<std::shared_ptr<std::string> > m_retStrVec;
    };

} // namespace Inklude

#endif // __INKLUDE_C_LUA_H__

